var e = require("../../@babel/runtime/helpers/interopRequireDefault"), t = e(require("../../@babel/runtime/regenerator")), a = require("../../@babel/runtime/helpers/asyncToGenerator"), r = require("../../utils/tool"), n = new (e(require("../../http/order")).default)();

Page({
    data: {
        mergeOrderId: "",
        orderDetail: {},
        logistics: {},
        showLogistics: !1,
        info: {}
    },
    onLoad: function(e) {
        this.setData({
            mergeOrderId: e.mergeOrderId
        }), this.getDetail();
    },
    getDetail: function() {
        var e = this;
        return a(t.default.mark(function a() {
            var r;
            return t.default.wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    return t.next = 2, n.getMergeOrderDetail(e.data.mergeOrderId);

                  case 2:
                    r = t.sent, e.setData({
                        orderDetail: r.data
                    }), e.data.orderDetail.orderStatus;

                  case 5:
                  case "end":
                    return t.stop();
                }
            }, a);
        }))();
    },
    showLogistics: function(e) {
        var r = this;
        return a(t.default.mark(function e() {
            var a;
            return t.default.wrap(function(e) {
                for (;;) switch (e.prev = e.next) {
                  case 0:
                    return e.prev = 0, wx.showLoading({
                        mask: !0,
                        title: "加载中…"
                    }), e.next = 4, n.LogisticsInformation(r.data.orderDetail.orderId);

                  case 4:
                    a = e.sent, r.setData({
                        showLogistics: !0,
                        info: a.data
                    }), e.next = 10;
                    break;

                  case 8:
                    e.prev = 8, e.t0 = e.catch(0);

                  case 10:
                    return e.prev = 10, wx.hideLoading(), e.finish(10);

                  case 13:
                  case "end":
                    return e.stop();
                }
            }, e, null, [ [ 0, 8, 10, 13 ] ]);
        }))();
    },
    getLogistics: function() {
        var e = this;
        return a(t.default.mark(function a() {
            var r;
            return t.default.wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    return t.prev = 0, wx.showLoading({
                        mask: !0,
                        title: "加载中…"
                    }), t.next = 4, n.Logistics(e.data.mergeOrderId);

                  case 4:
                    r = t.sent, e.setData({
                        logistics: r.data
                    }), t.next = 10;
                    break;

                  case 8:
                    t.prev = 8, t.t0 = t.catch(0);

                  case 10:
                    return t.prev = 10, wx.hideLoading(), t.finish(10);

                  case 13:
                  case "end":
                    return t.stop();
                }
            }, a, null, [ [ 0, 8, 10, 13 ] ]);
        }))();
    },
    onClose: function() {
        this.setData({
            showLogistics: !1
        });
    },
    cancelPick: function() {
        var e = this;
        return a(t.default.mark(function a() {
            return t.default.wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    return t.prev = 0, wx.showLoading({
                        mask: !0,
                        title: "加载中…"
                    }), t.next = 4, n.cancelPick(e.data.mergeOrderId);

                  case 4:
                    wx.hideLoading(), (0, r.toastToPage)("取消成功"), e.getBackPickRecord(), setTimeout(function() {
                        wx.navigateBack({
                            delta: 1
                        });
                    }, 1500), t.next = 13;
                    break;

                  case 10:
                    t.prev = 10, t.t0 = t.catch(0), wx.hideLoading();

                  case 13:
                  case "end":
                    return t.stop();
                }
            }, a, null, [ [ 0, 10 ] ]);
        }))();
    },
    payFreight: function() {
        var e = this;
        return a(t.default.mark(function a() {
            var i, o, s, c;
            return t.default.wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    return t.prev = 0, wx.showLoading({
                        mask: !0,
                        title: "加载中…"
                    }), t.next = 4, (0, r.promising)(wx.login)();

                  case 4:
                    return i = t.sent, t.next = 7, n.getPostWxPayInfo(i.code, e.data.mergeOrderId);

                  case 7:
                    o = t.sent, s = o.data, c = {
                        timeStamp: s.timeStamp,
                        nonceStr: s.nonceStr,
                        package: s.package,
                        paySign: s.paySign,
                        signType: s.signType,
                        success: function(t) {
                            wx.hideLoading(), (0, r.toastToPage)("申请发货成功"), e.getDetail(), e.getBackPickRecord();
                        },
                        fail: function(e) {
                            (0, r.toastToPage)("取消支付"), wx.hideLoading();
                        }
                    }, wx.requestPayment(c), t.next = 16;
                    break;

                  case 13:
                    t.prev = 13, t.t0 = t.catch(0), wx.hideLoading();

                  case 16:
                  case "end":
                    return t.stop();
                }
            }, a, null, [ [ 0, 13 ] ]);
        }))();
    },
    getBackPickRecord: function(e) {
        var t = getCurrentPages();
        t[t.length - 2].setData({
            isRefresh: !0
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {}
});